package com.self.springframework.beans.factory.xml;


import org.w3c.dom.Document;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.InputStream;

public class DefaultDocumentLoader implements DocumentLoader{
    @Override
    public Document loadDocument(InputStream inputStream) {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = factory.newDocumentBuilder();
            return docBuilder.parse(inputStream);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
